<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Weixin extends CI_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->library('CI_Wechat');
		$this->load->model('Weixin_model', 'WeixinModel');
		$this->load->helper('app');
	}

	public function debug(){
		$tmp = $this->ci_wechat->checkAuth();
		echo $tmp;
	}

	public function index() {
		$this->ci_wechat->valid();
		$type = $this->ci_wechat->getRev()->getRevType();
		switch ($type) {
			case Wechat::MSGTYPE_TEXT:
				$this->ci_wechat->text("hello, I'm wechat")->reply();
			case Wechat::MSGTYPE_EVENT:
				break;
			default:
				$this->ci_wechat->text("help info")->reply();
				break;
		}
	}

	public function menu(){
		$newmenu = array(
				'button' => array(
					array('type'=>'view','name'=>'点我领券','url'=>'http://benefit/lovchun.com/benefit/index'),	
					array('type'=>'view','name'=>'商家入驻','url'=>'http://benefit/lovchun.com/benefit/biz'),	
					array(
						'name'=>'个人中心',
						'sub_button'=>array(
							array('type'=>'view','name'=>'我的券','url'=>'http://benefit/lovchun.com/benefit/coupons'),
							array('type'=>'view','name'=>'核销券','url'=>'http://benefit/lovchun.com/benefit/check'),
							),
						),
					)
				);
		$ret = $this->ci_wechat->createMenu($newmenu);
	}

}
